import { createI18n } from "vue-i18n";
import en from "./en.json";
import zh from "./zh-CN.json";
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import enLocale from "element-plus/dist/locale/en.mjs";

const messages = {
  en: {
    ...en,
    ...enLocale,
  },
  "zh-CN": {
    ...zh,
    ...zhCn,
  },
};

const i18n = createI18n({
  legacy: false,
  locale: localStorage.getItem("locale") || "zh-CN",
  fallbackLocale: "en",
  messages,
});

export default i18n;
